package com.ahtcm.tcmlearning.utils.brushProblem;

public class AnswerOrChoiceToValueUtil {
    //切割选项取值辅助函数
    public  static String choiceToValue(String choice) {
        while (choice != null) {
            if (choice.substring(0, 1).equals("A") || choice.substring(0, 1).equals('a')) {
                return "0";
            }
            if (choice.substring(0, 1).equals("B") || choice.substring(0, 1).equals('b')) {
                return "1";
            }
            if (choice.substring(0, 1).equals("C") || choice.substring(0, 1).equals('c')) {
                return "2";
            }
            if (choice.substring(0, 1).equals("D") || choice.substring(0, 1).equals('d')) {
                return "3";
            }
            if (choice.substring(0, 1).equals("E") || choice.substring(0, 1).equals('e')) {
                return "4";
            }
        }
        return "-1";
    }
    public static String answerToValue(String answer){
        StringBuilder res=new StringBuilder();
        for (int i=0;i<answer.length();i++){
            if (answer.substring(i,i+1).equals("a")||answer.substring(i,i+1).equals("A"))
                res.append("0");
            if (answer.substring(i,i+1).equals("b")||answer.substring(i,i+1).equals("B"))
                res.append("1");
            if (answer.substring(i,i+1).equals("c")||answer.substring(i,i+1).equals("C"))
                res.append("2");
            if (answer.substring(i,i+1).equals("d")||answer.substring(i,i+1).equals("D"))
                res.append("3");
            if (answer.substring(i,i+1).equals("e")||answer.substring(i,i+1).equals("E"))
                res.append("4");
        }
        return res.toString();
    }
}